package com.yipao.db.dao.order;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import com.yipao.db.domain.Order;
import com.yipao.db.domain.order.YipaoOrderExample;

/**
 * 订单
 *
 * @author tianhao
 */
public interface OrderMapper {

    long countByExample(YipaoOrderExample example);


    int deleteByExample(YipaoOrderExample example);


    int deleteByPrimaryKey(Integer id);


    int insert(Order record);

    /**
     * 新增订单
     *
     * @param record
     * @return
     */
    int insertSelective(Order record);


    Order selectOneByExample(YipaoOrderExample example);


    Order selectOneByExampleSelective(@Param("example") YipaoOrderExample example, @Param("selective") Order.Column... selective);


    List<Order> selectByExampleSelective(@Param("example") YipaoOrderExample example, @Param("selective") Order.Column... selective);

    /**
     * 条件查询订单
     *
     * @param example
     * @return
     */
    List<Order> selectByExample(YipaoOrderExample example);


    Order selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") Order.Column... selective);


    Order selectByPrimaryKey(Integer id);


    Order selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);


    int updateByExampleSelective(@Param("record") Order record, @Param("example") YipaoOrderExample example);


    int updateByExample(@Param("record") Order record, @Param("example") YipaoOrderExample example);


    int updateByPrimaryKeySelective(Order record);


    int updateByPrimaryKey(Order record);


    int logicalDeleteByExample(@Param("example") YipaoOrderExample example);


    int logicalDeleteByPrimaryKey(Integer id);

    /**
     * 修改订单表达商品名称和口味
     *
     * @param order
     * @return
     */
    int updateGoodsNameAndTaste(Order order);

    /**
     * 修改订单的订单编号,微信支付返回重复的商户编号时调用
     *
     * @param id      订单id
     * @param orderSn 订单编号
     * @return
     */
    int updateOrderSn(@Param("id") Integer id, @Param("orderSn") String orderSn);
}
